[...all].vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <route lang="yaml">
  2. name: notFound
  3. meta:
  4. title: 找不到页面
  5. constant: true
  6. layout: false
  7. </route>
  8. <script setup lang="ts">
  9. import { useRouter } from 'vue-router'
  10. import useSettingsStore from '@/store/modules/settings'
  11. import { onMounted, ref } from 'vue'
  12. const router = useRouter()
  13. const settingsStore = useSettingsStore()
  14. const data = ref({
  15. inter: Number.NaN,
  16. countdown: 5,
  17. })
  18. onBeforeRouteLeave(() => {
  19. data.value.inter && window.clearInterval(data.value.inter)
  20. })
  21. onMounted(() => {
  22. data.value.inter = window.setInterval(() => {
  23. data.value.countdown--
  24. if (data.value.countdown === 0) {
  25. data.value.inter && window.clearInterval(data.value.inter)
  26. goBack()
  27. }
  28. }, 1000)
  29. })
  30. function goBack() {
  31. router.push(settingsStore.settings.home.fullPath)
  32. }
  33. </script>
  34. <template>
  35. <div class="absolute left-[50%] top-[50%] flex flex-col items-center justify-between lg-flex-row -translate-x-50% -translate-y-50% lg-gap-12">
  36. <SvgIcon name="404" class="text-[300px] lg-text-[400px]" />
  37. <div class="flex flex-col gap-4">
  38. <h1 class="m-0 text-6xl font-sans">
  39. 404
  40. </h1>
  41. <div class="mx-0 text-xl text-stone-5">
  42. 抱歉,你访问的页面不存在
  43. </div>
  44. <div>
  45. <HButton @click="goBack">
  46. {{ data.countdown }} 秒后,返回首页
  47. </HButton>
  48. </div>
  49. </div>
  50. </div>
  51. </template>